<template>
  <el-dialog
    :title="editObj.status ? '确定停用？' : '确定启用？'"
    :visible="visible"
    width="30%"
    @close="closeFn"
  >
    <span>确定要{{ str }}：{{ editObj.name }}吗？</span>
    <span slot="footer" class="dialog-footer">
      <el-button @click="closeFn">取 消</el-button>
      <el-button type="primary" @click="submit">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>
import { EditStatu, EditKqgl } from '@/api/warehouse'
export default {
  props: {
    visible: {
      type: Boolean,
      required: true
    },
    editObj: {
      type: Object,
      required: true
    },
    str: {
      type: String,
      required: true
    }
  },
  data () {
    return {

    }
  },
  computed: {},
  created () {},
  mounted () {},
  methods: {
    closeFn () {
      this.$emit('update:visible', false)
    },
    async submit () {
      if (this.editObj.status === 1) {
        console.log(this.editObj.status)
        if (this.editObj.type) await EditStatu({ id: this.editObj.id, status: 0 })
        if (this.editObj.bearingType) await EditKqgl(({ id: this.editObj.id, status: 0 }))
      } else if (this.editObj.status === 0) {
        if (this.editObj.type) await EditStatu({ id: this.editObj.id, status: 1 })
        if (this.editObj.bearingType) await EditKqgl(({ id: this.editObj.id, status: 1 }))
      }
      this.$emit('editGenXin')
      this.$message.success('状态修改成功')
      this.closeFn()
    }
  }
}
</script>
<style lang="scss" scoped></style>
